import config from './utils/config.js'
import { defineConfig } from 'vite';
import uni from '@dcloudio/vite-plugin-uni';
import fs from 'node:fs'
import path from 'node:path'
import mkcert from "vite-plugin-mkcert"
export default defineConfig({
	plugins: [uni(),mkcert({autoUpgrade: false})],
	// #ifdef H5
	server: {
		https: false,
		proxy: {
			"/apiH5": {
				target: config.proxy,
				"changeOrigin": true,
				rewrite: (path) => path.replace(/^\/apiH5/, '') ,// 重写 url 的 path 部分
			},
			"/apiGptp": {
				target: config.proxy1,
				"changeOrigin": true,
				rewrite: (path) => path.replace(/^\/apiGptp/, '') ,// 重写 url 的 path 部分
			},
			"/txapi": {
				target:'https://asr.tencentcloudapi.com',
				"changeOrigin": true,
				rewrite: (path) => path.replace(/^\/txapi/, '') ,// 重写 url 的 path 部分
			},
			"/wsapi.io": {
				target:'ws://gpt.gxmob.cn',
				ws: true,
				"changeOrigin": true,
				rewrite: (path) => path.replace(/^\/wsapi.io/, '') ,// 重写 url 的 path 部分
			}
		},
		host: '0.0.0.0',
		port: '80'
	},
	// #endif
	build: {
		minify: 'terser',
		terserOptions: {
			compress: {
				drop_console: false,
			},
		},
	},
});